home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10465 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: cs.tu-berlin.de!news
  2. From: Roman Lechtchinsky <wolfro@cs.tu-berlin.de>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Operator overloading
  5. Date: Fri, 08 Mar 1996 01:48:03 +0100
  6. Organization: Technical University of Berlin
  7. Message-ID: <313F83C3.4E90@cs.tu-berlin.de>
  8. References: <313F19B5.41C6@lfa.uni-wuppertal.de>
  9. NNTP-Posting-Host: 130.149.17.231
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win95; I)
  14.  
  15. Oliver Heinz wrote:
  16. > Hello out there,
  17. > can somebody explain to me this strange looking operator overloading:
  18. > const T& operator[](unsigned long int index) const;
  19. > I know, it is an subscription overloading, for something like
  20. > v[i], where i is of type unsigned long int and v of type T.
  21. > What's the meaning of the const at the end
  22.  
  23. The const at the end means that this member function does not modify the 
  24. its object. E. g. if you have something like this:
  25.  
  26. const MyArray array(...);
  27.  
  28. then a call like array[...] is allowed only if operator[] is declared const.
  29.  
  30. > and the beginning of the line ?
  31.  
  32. This one means that the object returned by the operator is const.
  33.  
  34. Bye
  35.  
  36. Roman
  37.